#-*- coding: utf8 -*-
from tutor.script import *
from tutor.plugin.maple import *

# variáveis úteis
half = M('1/2')
t = M.t
_i, _j, _k = M('_i, _j, _k')
rr = M('`..`')

# parâmetros iniciais
a = 2*M(oneof(1,2,3,4))
r = oneof(2,3,4,6)
s = oneof(2,4) * oneof(-1, 1)

# ATENCAO! --- prova --------------------------------------------
r, s = 3, -2
a = M(6)

# raios
raT = r * t
rbT = s * t

# potencial
U = x*y + a*y**2/2
Uerr1 = x*y
Uerr2 = y**2/2
F = diff(U, x) * _i + diff(U, y) * _j
print('a: %s, r,s: %s\nF: %s' % (a,(r,s),F))

# pontos
P = (x==r*M.Pi/8, y==s*M.Pi/8)
Pe = (x==r*M.Pi/4, y==s*M.Pi/4)

# respostas
work = M.subs(P, U)
distract1 = M.subs(Pe, U)
distract2 = M.subs(P, Uerr1)
distract3 = M.subs(P, Uerr2)
print('work: %s\ndistractors: %s, %s, %s' % (work, distract1, distract2, distract3))
